import csv
import random

def num2str(num):
    if num < 10:
        return '0' + str(num)
    else:
        return str(num)

def split_csv(input_file, max_lines_per_file):
    with open(input_file, 'r', encoding='utf-8') as file:
        reader = csv.reader(file)
        lines = list(reader)

    random.shuffle(lines)  # Shuffle the lines

    for i in range(0, len(lines), max_lines_per_file):
        output_file = f'tpo_kmf_split_{num2str(i // max_lines_per_file + 1)}.csv'
        with open(output_file, 'w', encoding='utf-8', newline='') as file:
            writer = csv.writer(file)
            writer.writerows(lines[i:i + max_lines_per_file])

# Usage
input_csv = 'tpo_kmf.csv'  # Replace with your input file path
split_csv(input_csv, 50)
